(function(window, document, undefined){
	var amrio = (function(){
		var amrio = $ = function(selector){
			return new amrio.fn.init(selector);
		}, 
		quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
		readyList = [];
		
		amrio.fn = amrio.prototype = {
			constructor: amrio,
			init: function(selector){
				
				var match, elem, ret, doc;
				
				//handle undefined
				if(!selector){
					return this;
				};
				
				//handle DOMElement
				if(selector.nodeType){
					this.context = this[0] = selector;
					this.length = 1;
					return this;
				};
				
				// handle body
				if ( selector === "body" && document.body ) {
					this.context = document;
					this[0] = document.body;
					this.selector = selector;
					this.length = 1;
					return this;
				};
				
				//handle type string
				if(typeof selector === "string"){
					var expr = /^\w+$|#\w+$|.\w+$/
					var re = expr.exec(selector);
					if(selector.length >= 3 && selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">"){
						match = [null, selector, null];
					}else{
						match = quickExpr.exec(selector);
					};
					
					if(!match){
						var match = selector.split(".");
						//handle .class
						if(match[1]){
							var set = document.getElementsByTagName(match[0] || "*");
							var len = 0;
							for(var i = 0;i < set.length;i++){
								set[i].className == match[1] &&
								(this[len] = set[i], len++, this.length = len, this.context = document);
							};
						};
						return this;
					};
					//handle #id
					if(match[2]){
						this[0] = document.getElementById(match[2]);
						this.context = document;
						this.length = 1;
						return this;	
					};
					//typeof string end
				};
				
				if(typeof selector === "object"){
					if($.isAmrio(selector)) return selector;
					this[0] = selector;
					this.length = 1;
					return this;
					//typeof object end
				};
				
				//handle function
				if($.isFunc(selector)){
					$.ready(selector);
				};
				
				//init end
			}
			// fn extend end
		};
		
		amrio.fn.init.prototype = amrio.fn;
	
		amrio.extend = amrio.fn.extend = function(target){
			for(var name in target){
				this[name] = target[name];
			};
			
			//extend end
		};
		
		amrio.fn.extend({
			show: function(){ 
				$.each(this,function(){
					this.style.display = "block";	
				});
				//show end
			},
			hide: function(){
				$.each(this,function(){
					this.style.display = "none";	
				});
				//hide end
			}
		});	
		
		amrio.extend({
			log: function(obj){ 
				console.log && console.log(obj); 
				//log end
			},
			ready: function(fn){
				readyList.push(fn);
				document.onreadystatechange || (document.onreadystatechange = amrio.bindReady);	
				//ready end
			},
			bindReady: function(){
				if(document.readyState === "complete"){
					while(readyList.length){ 
						readyList.shift().call(amrio);
					};
				};
				//bindReady end
			},
			each: function(object, callback, args){
				var name,i = 0,length = object.length,isObj = length === undefined || $.isFunc(object); 
				if(args){
					if(isObj){
						for(name in object){
							if(callback.call(object[name], args) === false){
								break;
							}
						}
					}else{
						for(;i < length;){
							if(callback.call(object[i++], args) === false){
								break;
							}
						}	
					}
				}else{
					if(isObj){
						for(name in object){
							if(callback.call(object[name], name, object[name]) === false){
								break;
							}
						}
					}else{
						for(;i < length;){
							if(callback.call(object[i], i, object[i++]) === false){
								break;
							}
						}	
					}
				}
				
				//each end	
			},
			isFunc: function(func){
				return (typeof func === "function");
				//isFunc end	
			},
			isAmrio: function(obj){
				return (obj.constructor === amrio);
				//isAmrio end	
			}
			
			//amrio.fx.extend end
		});
		
		return amrio;
		// build amrio end
	}());
	
	//register
	window.amrio = window.$ = amrio;
	
	// begin amrio end
})(window, window.document);